package com.shqcjd.preinstallmobile.ui.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.preinstallmobile.R;
import com.shqcjd.preinstallmobile.model.pojo.TaskNtrackBean;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 轨迹列表
 * Created by sy on 2019/4/30.
 */

public class NtrackAdapter extends BaseQuickAdapter<TaskNtrackBean.ItemsBean,NtrackAdapter.ViewHolder> {
    public NtrackAdapter() {
        super(R.layout.item_ntrack_layout);
    }

    @Override
    protected void convert(ViewHolder helper, TaskNtrackBean.ItemsBean item) {
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.ic_default_small)	//加载成功之前占位图
                .error(R.mipmap.ic_default_small)	//加载错误之后的错误图
                .centerInside();
//                .centerCrop();//指定图片的缩放类型为centerCrop （等比例缩放图片，直到图片的宽高都
        Glide.with(mContext)
                .load(item.img)
                .apply(options)
                .into(helper.iv_img);
        helper.tv_title.setText(item.name);
        helper.tv_state.setText(item.task_status);
        helper.tv_name.setText("巡检员:"+item.user_name);
        helper.tv_time.setText("巡检时间:"+item.task_time);
    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.iv_img)
        ImageView iv_img;
        @BindView(R.id.tv_title)
        TextView tv_title;
        @BindView(R.id.tv_state)
        TextView tv_state;
        @BindView(R.id.tv_name)
        TextView tv_name;
        @BindView(R.id.tv_time)
        TextView tv_time;
        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
